#include<cstdio>
#include<cstring>
using namespace std;

char month_Haab[19][20]={"pop","no","zip","zotz","tzec","xul","yoxkin","mol","chen","yax","zac","ceh","mac","kankin","muan","pax","koyab","cumhu","uayet"};
char name_day_Tzolkin[20][20]={"imix","ik","akbal","kan","chicchan","cimi","manik","lamat","muluk","ok","chuen","eb","ben","ix","mem","cib","caban","eznab","canac","ahau"};

int main()
{
    int day_h,year_h;
    char month_h[20];
    int day_t,year_t,month_t;
    int sum;
    scanf("%d",&sum);
    printf("%d\n",sum);
    while(sum--)
    {
         scanf("%d. %s %d",&day_h,month_h,&year_h);
         int tmp_month=-1;
         while(strcmp(month_h,month_Haab[++tmp_month])!=0);
         long tmp_day=year_h*365+day_h+1+tmp_month*20;
         printf("%d %s %d\n",(tmp_day-1)%13+1,name_day_Tzolkin[(tmp_day-1)%20],(tmp_day-1)/260);
    }
    return 0;
}
